#include <opencv2\opencv.hpp>

using namespace cv;

int main(void) {
	String fn = "C:\\Program Files\\opencv\\sources\\samples\\data\\lena.jpg";
	Mat image, hsvImage, bgrChannels[3], hsvChannels[3];
	image = imread(fn);
	imshow("Hello World!", image);
	waitKey(0);

	Mat red = Mat::zeros(image.rows, image.cols, CV_8UC3);
	Mat green = Mat::zeros(image.rows, image.cols, CV_8UC3);
	Mat blue = Mat::zeros(image.rows, image.cols, CV_8UC3);
	Mat channels[] = { blue, green, red };
	int from_to[] = { 0, 0, 1, 4, 2, 8 };
	mixChannels(&image, 1, channels, 3, from_to, 3);
	imshow("Red", red);
	imshow("Green", green);
	imshow("Blue", blue);	

	cvtColor(image, hsvImage, COLOR_BGR2HSV);
	split(hsvImage, hsvChannels);
	imshow("Hue", hsvChannels[0]);
	imshow("Saturation", hsvChannels[1]);
	imshow("Value", hsvChannels[2]);

	waitKey(0);
}
